-
-
Notifications
You must be signed in to change notification settings - Fork 241
London | 25-ITP-September |Sophia Mohamed |Sprint 3 | 2 practice tdd #842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
London | 25-ITP-September |Sophia Mohamed |Sprint 3 | 2 practice tdd #842
Conversation
London | 25-ITP-Sept | Sophia Mohamed | Sprint 1 | coursework/sprint-1
|
Your PR's title isn't in the expected format. Please check the expected title format, and update yours to match. Reason: Sprint part (Coursework/sprint 3) doesn't match expected format (example: 'Sprint 2', without quotes) If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Your PR's title isn't in the expected format. Please check the expected title format, and update yours to match. Reason: Sprint part (Coursework/sprint 3) doesn't match expected format (example: 'Sprint 2', without quotes) If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
| test("should count multiple occurrences of a character", () => { | ||
| const str = "aaaaa"; | ||
| const char = "a"; | ||
| const count = countChar(str, char); | ||
| const Char = "a"; | ||
| const count = countChar(str,Char); | ||
| expect(count).toEqual(5); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also merge this test into the previous test (they both test "multiple occurrences").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the test
| test("should return '1st' for 1", () => { | ||
| expect(getOrdinalNumber(1)).toEqual("1st"); | ||
| }); | ||
| test("should return 'th' for 11, 12, 13", () => { | ||
| expect(getOrdinalNumber(11)).toBe("11th"); | ||
| expect(getOrdinalNumber(12)).toBe("12th"); | ||
| expect(getOrdinalNumber(13)).toBe("13th"); | ||
| }); | ||
| test("should return correct ordinal for numbers > 20", () => { | ||
| expect(getOrdinalNumber(21)).toBe("21st"); | ||
| expect(getOrdinalNumber(22)).toBe("22nd"); | ||
| expect(getOrdinalNumber(23)).toBe("23rd"); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To ensure thorough testing, we need broad scenarios that cover all possible cases.
-
Listing individual values can quickly lead to an unmanageable number of test cases. You can consider generalise the first test to cover all numbers ending in 1 (but not in 11).
-
Creating a category for "11, 12, 13" is good. You can also generalise the test to cover all numbers ending in 11, 12, 13.
-
"All numbers > 20" as one category might be too broad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More testing scenarios were added
cjyuan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good. Well done.
| //test("should count multiple occurrences of a character", () => { | ||
| // const str = "aaaaa"; | ||
| //const Char = "a"; | ||
| //const count = countChar(str,Char); | ||
| // expect(count).toEqual(5); | ||
| //}); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep the code clean, why not delete all unused code?
Learners, PR Template
Self checklist
Changelist
I have completed all the required tasks and tests